#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>

void sort_by_parity(int* p, int sz)
{
	int* left = p;
	int* right = p + sz - 1;
	while (left <= right)
	{
		if (*left % 2 != 0)
		{
			left++;
		}
		if (*right % 2 == 0)
		{
			right--;
		}
		if (*left%2 == 0 && *right % 2 != 0)
		{
			int tmp = *left;
			*left = *right;
			*right = tmp;
			left++;
			right--;
		}
	}
}


int main()
{
	int arr[] = { 0,1,2,3,4,5,6,7,8,9 };
	int sz = sizeof(arr) / sizeof(arr[0]);
	int i = 0;
	
	sort_by_parity(arr, sz);
	for (i = 0; i < sz; i++)
	{
		printf("%d ", arr[i]);
	}
	
	return 0;
}    